__all__ = ['regions', 'Region', 'get_region']
regions = ['al', 'ak', 'az', 'ar', 'ca', 'co', 'ct', 'de', 'dc', 'fl', 'ga',
'hi', 'id', 'il', 'in', 'ia', 'ks', 'ky', 'la', 'me', 'md', 'ma',
'mi', 'mn', 'ms', 'mo', 'mt', 'ne', 'nb', 'nb|ne', 'nv', 'nh', 'nj',
'nm', 'ny', 'nc', 'nd', 'oh', 'ok', 'or', 'pa', 'ri', 'sc', 'sd',
'tn', 'tx', 'ut', 'vt', 'va', 'wa', 'wv', 'wi', 'wy', 'wvfbi',
'ncic', 'unknown']
#to apply global rules do not return a value on region function
class Region(object):
[docs] def __init__(self, state):
self.state = state.lower().split('|')
def __str__(self):
return str(self.state)
def priority(self):
[docs] return 10
def get_state(self):
[docs] return self.state
def get_region(region):
[docs] region = region.lower()
if region in regions:
return regions[region]
raise RuleParsingError('Unknown region: %r' % region)
regions = dict((st, Region(st)) for st in regions)